package com.situ.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo1 {
    public static void main(String[] args) {
        //一池五线程
        //ExecutorService threadPool = Executors.newFixedThreadPool(5);
        //一池一线程
        //ExecutorService threadPool = Executors.newSingleThreadExecutor();
        ExecutorService threadPool = Executors.newCachedThreadPool();
        //10个顾客
        for (int i = 1; i <= 10; i++) {
            final int index = i;
            threadPool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + " 为第" + index + "个客户办理业务");
                }
            });
        }

    }
}
